package Behavior.Strategy;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * Author  zxy
 * Date  2022/12/30 下午 3:31
 */
public class CombineStrategy implements DiscountStrategy{

    @Override
    public BigDecimal getDiscount(BigDecimal total) {
        total = total.compareTo(BigDecimal.valueOf(100)) >= 0 ?
                total.subtract(BigDecimal.valueOf(20)) : total;
        return total.multiply(new BigDecimal("0.3")).setScale(2, RoundingMode.DOWN);
    }

}
